﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Polymorphic
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("你要计算什么的是加减乘除的那一个");
            Console.WriteLine("1 两数相加 2 两数相减 3 两数相乘 4 两数相除");
            int HH = int.Parse(Console.ReadLine());
            switch (HH)
            {
                case 1:
                    Plus a = new Plus();
                    a.DisplayResult();
                    break;
                case 2:
                    Subtract b = new Subtract();
                    b.DisplayResult();
                    break;
                case 3:
                    Ride c = new Ride();
                    c.DisplayResult();
                    break;
                case 4:
                    Divide d = new Divide();
                    d.DisplayResult();
                    break;
            }
            Console.ReadKey();
        }
    }
    class Calculate 
    {
        protected int Top1;
        protected int Top2;
        public int TT
        {
            get { return this.Top1; }
            set { this.Top1 = value; }
        }
        public int EE
        {
            get { return this.Top2; }
            set { this.Top2 = value; }
        }
        public Calculate(int top1,int top2) 
        {
            this.Top1 = top1;
            this.Top2 = top2;
        }
        public Calculate() { }
        public virtual void DisplayResult() 
        {
            Console.WriteLine("请输入第一个数：");
            Top1 = int.Parse(Console.ReadLine());
            Console.WriteLine("请输入第二个数：");
            Top2= int.Parse(Console.ReadLine());
        }
    }
    class Plus: Calculate //加
    {
        public override void DisplayResult() 
        {
            base.DisplayResult();
            int AA = Top1 + Top2;
            Console.WriteLine("相加为{0}",AA);
        }
    }
    class Subtract : Calculate //减
    {
        public override void DisplayResult()
        {
            base.DisplayResult();
            int AA = Top1 - Top2;
            Console.WriteLine("相减为{0}", AA);
        }
    }
    class Ride : Calculate //乘
    {
        public override void DisplayResult()
        {
            base.DisplayResult();
            int AA = Top1 * Top2;
            Console.WriteLine("相乘为{0}", AA);
        }
    }
    class Divide : Calculate //除
    {
        public override void DisplayResult()
        {
            base.DisplayResult();
            int AA = Top1 / Top2;
            Console.WriteLine("相除为{0}", AA);
        }
    }
}
